<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Rinda::TupleSpace - rinda: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><span class="include">DRbUndumped</span>
    <li><span class="include">MonitorMixin</span>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li class="calls-super" ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-create_entry">#create_entry</a>
    <li ><a href="#method-i-keep_clean">#keep_clean</a>
    <li ><a href="#method-i-move">#move</a>
    <li ><a href="#method-i-need_keeper-3F">#need_keeper?</a>
    <li ><a href="#method-i-notify">#notify</a>
    <li ><a href="#method-i-notify_event">#notify_event</a>
    <li ><a href="#method-i-read">#read</a>
    <li ><a href="#method-i-read_all">#read_all</a>
    <li ><a href="#method-i-start_keeper">#start_keeper</a>
    <li ><a href="#method-i-take">#take</a>
    <li ><a href="#method-i-write">#write</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Rinda::TupleSpace">
    <h1 id="class-Rinda::TupleSpace" class="class">
      class Rinda::TupleSpace
    </h1>

    <section class="description">
    
<p>The Tuplespace manages access to the tuples it contains, ensuring mutual exclusion requirements are met.</p>

<p>The <code>sec</code> option for the write, take, move, read and notify methods may either be a number of seconds or a Renewer object.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(period=60)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new <a href="TupleSpace.html"><code>TupleSpace</code></a>.  <code>period</code> is used to control how often to look for dead tuples after modifications to the <a href="TupleSpace.html"><code>TupleSpace</code></a>.</p>

<p>If no dead tuples are found <code>period</code> seconds after the last modification, the <a href="TupleSpace.html"><code>TupleSpace</code></a> will stop looking for dead tuples.</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 437</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">period</span>=<span class="ruby-value">60</span>)
  <span class="ruby-keyword">super</span>()
  <span class="ruby-ivar">@bag</span> = <span class="ruby-constant">TupleBag</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-ivar">@read_waiter</span> = <span class="ruby-constant">TupleBag</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-ivar">@take_waiter</span> = <span class="ruby-constant">TupleBag</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-ivar">@notify_waiter</span> = <span class="ruby-constant">TupleBag</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-ivar">@period</span> = <span class="ruby-identifier">period</span>
  <span class="ruby-ivar">@keeper</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-move" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">move</span><span
                                class="method-args">(port, tuple, sec=nil) { |template| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Moves <code>tuple</code> to <code>port</code>.</p>

                              <div class="method-source-code" id="move-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 484</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">move</span>(<span class="ruby-identifier">port</span>, <span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">template</span> = <span class="ruby-constant">WaitTemplateEntry</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>)
  <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">template</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">entry</span> = <span class="ruby-ivar">@bag</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">template</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">entry</span>
      <span class="ruby-identifier">port</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">value</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">port</span>
      <span class="ruby-ivar">@bag</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">entry</span>)
      <span class="ruby-identifier">notify_event</span>(<span class="ruby-string">&#39;take&#39;</span>, <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">value</span>)
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">port</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">value</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">RequestExpiredError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">expired?</span>

    <span class="ruby-keyword">begin</span>
      <span class="ruby-ivar">@take_waiter</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">template</span>)
      <span class="ruby-identifier">start_keeper</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">expires</span>
      <span class="ruby-keyword">while</span> <span class="ruby-keyword">true</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-constant">RequestCanceledError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">canceled?</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-constant">RequestExpiredError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">expired?</span>
        <span class="ruby-identifier">entry</span> = <span class="ruby-ivar">@bag</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">template</span>)
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">entry</span>
          <span class="ruby-identifier">port</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">value</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">port</span>
          <span class="ruby-ivar">@bag</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">entry</span>)
          <span class="ruby-identifier">notify_event</span>(<span class="ruby-string">&#39;take&#39;</span>, <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">value</span>)
          <span class="ruby-keyword">return</span> <span class="ruby-identifier">port</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">value</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">template</span>.<span class="ruby-identifier">wait</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-ivar">@take_waiter</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">template</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-notify" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">notify</span><span
                                class="method-args">(event, tuple, sec=nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Registers for notifications of <code>event</code>.  Returns a <a href="NotifyTemplateEntry.html"><code>NotifyTemplateEntry</code></a>. See <a href="NotifyTemplateEntry.html"><code>NotifyTemplateEntry</code></a> for examples of how to listen for notifications.</p>

<p><code>event</code> can be:</p>
<dl class="rdoc-list note-list"><dt>‘write’
<dd>
<p>A tuple was added</p>
</dd><dt>‘take’
<dd>
<p>A tuple was taken or moved</p>
</dd><dt>‘delete’
<dd>
<p>A tuple was lost after being overwritten or expiring</p>
</dd></dl>

<p>The <a href="TupleSpace.html"><code>TupleSpace</code></a> will also notify you of the ‘close’ event when the <a href="NotifyTemplateEntry.html"><code>NotifyTemplateEntry</code></a> has expired.</p>

                              <div class="method-source-code" id="notify-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 567</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">notify</span>(<span class="ruby-identifier">event</span>, <span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">template</span> = <span class="ruby-constant">NotifyTemplateEntry</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">event</span>, <span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@notify_waiter</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">template</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">template</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read</span><span
                                class="method-args">(tuple, sec=nil) { |template| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Reads <code>tuple</code>, but does not remove it.</p>

                              <div class="method-source-code" id="read-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 521</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read</span>(<span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">template</span> = <span class="ruby-constant">WaitTemplateEntry</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>)
  <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">template</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">entry</span> = <span class="ruby-ivar">@bag</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">template</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">value</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">entry</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">RequestExpiredError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">expired?</span>

    <span class="ruby-keyword">begin</span>
      <span class="ruby-ivar">@read_waiter</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">template</span>)
      <span class="ruby-identifier">start_keeper</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">expires</span>
      <span class="ruby-identifier">template</span>.<span class="ruby-identifier">wait</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">RequestCanceledError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">canceled?</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">RequestExpiredError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">expired?</span>
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">found</span>
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-ivar">@read_waiter</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">template</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_all" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_all</span><span
                                class="method-args">(tuple)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns all tuples matching <code>tuple</code>.  Does not remove the found tuples.</p>

                              <div class="method-source-code" id="read_all-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 545</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_all</span>(<span class="ruby-identifier">tuple</span>)
  <span class="ruby-identifier">template</span> = <span class="ruby-constant">WaitTemplateEntry</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">tuple</span>, <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">entry</span> = <span class="ruby-ivar">@bag</span>.<span class="ruby-identifier">find_all</span>(<span class="ruby-identifier">template</span>)
    <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">e</span>.<span class="ruby-identifier">value</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-take" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">take</span><span
                                class="method-args">(tuple, sec=nil, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes <code>tuple</code></p>

                              <div class="method-source-code" id="take-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 477</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">take</span>(<span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">move</span>(<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-write" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">write</span><span
                                class="method-args">(tuple, sec=nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds <code>tuple</code></p>

                              <div class="method-source-code" id="write-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 450</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write</span>(<span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">create_entry</span>(<span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>)
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">expired?</span>
      <span class="ruby-ivar">@read_waiter</span>.<span class="ruby-identifier">find_all_template</span>(<span class="ruby-identifier">entry</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">template</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">template</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">tuple</span>)
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">notify_event</span>(<span class="ruby-string">&#39;write&#39;</span>, <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">value</span>)
      <span class="ruby-identifier">notify_event</span>(<span class="ruby-string">&#39;delete&#39;</span>, <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">value</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-ivar">@bag</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">entry</span>)
      <span class="ruby-identifier">start_keeper</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">expires</span>
      <span class="ruby-ivar">@read_waiter</span>.<span class="ruby-identifier">find_all_template</span>(<span class="ruby-identifier">entry</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">template</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">template</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">tuple</span>)
      <span class="ruby-keyword">end</span>
      <span class="ruby-ivar">@take_waiter</span>.<span class="ruby-identifier">find_all_template</span>(<span class="ruby-identifier">entry</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">template</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">template</span>.<span class="ruby-identifier">signal</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">notify_event</span>(<span class="ruby-string">&#39;write&#39;</span>, <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">value</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">entry</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-create_entry" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create_entry</span><span
                                class="method-args">(tuple, sec)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="create_entry-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 577</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create_entry</span>(<span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>)
  <span class="ruby-constant">TupleEntry</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">tuple</span>, <span class="ruby-identifier">sec</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-keep_clean" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">keep_clean</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes dead tuples.</p>

                              <div class="method-source-code" id="keep_clean-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 584</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">keep_clean</span>
  <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
    <span class="ruby-ivar">@read_waiter</span>.<span class="ruby-identifier">delete_unless_alive</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">e</span>.<span class="ruby-identifier">signal</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-ivar">@take_waiter</span>.<span class="ruby-identifier">delete_unless_alive</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">e</span>.<span class="ruby-identifier">signal</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-ivar">@notify_waiter</span>.<span class="ruby-identifier">delete_unless_alive</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">e</span>.<span class="ruby-identifier">notify</span>([<span class="ruby-string">&#39;close&#39;</span>])
    <span class="ruby-keyword">end</span>
    <span class="ruby-ivar">@bag</span>.<span class="ruby-identifier">delete_unless_alive</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">notify_event</span>(<span class="ruby-string">&#39;delete&#39;</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">value</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-need_keeper-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">need_keeper?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the tuplespace to see if it needs cleaning.</p>

                              <div class="method-source-code" id="need_keeper-3F-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 631</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">need_keeper?</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@bag</span>.<span class="ruby-identifier">has_expires?</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@read_waiter</span>.<span class="ruby-identifier">has_expires?</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@take_waiter</span>.<span class="ruby-identifier">has_expires?</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@notify_waiter</span>.<span class="ruby-identifier">has_expires?</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-notify_event" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">notify_event</span><span
                                class="method-args">(event, tuple)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Notifies all registered listeners for <code>event</code> of a status change of <code>tuple</code>.</p>

                              <div class="method-source-code" id="notify_event-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 605</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">notify_event</span>(<span class="ruby-identifier">event</span>, <span class="ruby-identifier">tuple</span>)
  <span class="ruby-identifier">ev</span> = [<span class="ruby-identifier">event</span>, <span class="ruby-identifier">tuple</span>]
  <span class="ruby-ivar">@notify_waiter</span>.<span class="ruby-identifier">find_all_template</span>(<span class="ruby-identifier">ev</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">template</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">template</span>.<span class="ruby-identifier">notify</span>(<span class="ruby-identifier">ev</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-start_keeper" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">start_keeper</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a thread that scans the tuplespace for expired tuples.</p>

                              <div class="method-source-code" id="start_keeper-source">
            <pre><span class="ruby-comment"># File rinda/tuplespace.rb, line 615</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">start_keeper</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@keeper</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@keeper</span>.<span class="ruby-identifier">alive?</span>
  <span class="ruby-ivar">@keeper</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">while</span> <span class="ruby-keyword">true</span>
      <span class="ruby-identifier">sleep</span>(<span class="ruby-ivar">@period</span>)
      <span class="ruby-identifier">synchronize</span> <span class="ruby-keyword">do</span>
        <span class="ruby-keyword">break</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">need_keeper?</span>
        <span class="ruby-identifier">keep_clean</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

